package cn.java63.printer2.printer;

public class TextPaper implements Page {
    private int linewords;//一行几个字
    private int pageLines;//一页多少行
    public void print(String content) {
        char []cr=content.toCharArray();
        int word=0;
        int line=0;
        int page=1;
        for(char c:cr){
            System.out.print(c);
            word++;
            if(word>=linewords){
                //一行到头
                word=0;
                line++;
                System.out.println();
                if(line>=pageLines){
                    line=0;
                    System.out.println(String.format("----%d-",page++));

                }
            }
        }
        if(line!=0||word!=0)
            System.out.println(String.format("\n----%d-",page++));

    }
    public void setLinewords(int linewords) {
        this.linewords = linewords;
    }

    public void setPageLines(int pageLines) {
        this.pageLines = pageLines;
    }
}
